import os
from flask import Flask
from application.config import BaseConfig

from application.extensions import init_plugs

from application.api import init_bps
from application.ws import init_ws


def create_app():
    app = Flask(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

    # 引入配置
    app.config.from_object(BaseConfig)

    # 注册flask组件
    init_plugs(app)

    # 注册蓝图
    init_bps(app)

    # 启动 websocket 服务
    init_ws(app)


    return app
